#ifndef __MANAGER_H__
#define __MANAGER_H__

#include "entities.h"
#include "database.h"

class ResourceManager {
	DatabaseConnector	connector;
	bool				connected;
public:
	bool				connect_db(string user, string passwd, string dbname);
	void				disconnect_db();
	
	Goods			getGoods(int gid);
	Facility			getFacility(int fid);
	City				getCity(int cid);
	Nation			getNation(int nid);
	ShipSpec			getShipSpec(int spid);
	Ship				getShip(int sid);
	Character			getCharacter(int chid);
	Player			getPlayer(int pid);
	
	/* TODO: Add Methods Retrieving Data in Mapping Table */
	
	map<int,int>		getGoodsInFacility(int fid);
	map<int,int>		getGoodsInShip(int sid);
	
	/* TODO: Add methods commiting data to database */
	
	bool				isGoodsInCity(int cid, int gid);
	bool				addGoodsToCity(int cid, int gid, int amount);
	bool				subGoodsFromCity(int cid, int gid, int amount);
	
	bool				isGoodsInShip(int sid, int gid);
	bool				addGoodsToShip(int sid, int gid, int amount);
	bool				subGoodsFromShip(int sid, int gid, int amount);
	
	bool				addShipToChar(int chid, int sid);
	bool				delShipFromChar(int chid, int sid);
	
	/* Methods adding new records to database */
	/* They returns primary key (id) value of created record */
	
	int				createNewGoods(Goods goods);
	int				createNewShip(Ship ship);
	int				createNewChar(Character chara);
};

#endif
